package com.student.controller;

import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authz.UnauthenticatedException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by zhudong on 2016/9/25.
 */
@ControllerAdvice
public class AccessExceptionHandler {
    /*@ExceptionHandler(UnauthenticatedException.class)
    public ModelAndView notLogin(Exception ex){
        System.out.println(ex);
        ModelAndView model = new ModelAndView("error");
        model.addObject("ex",ex);
        return model;
    }
*/
    @ExceptionHandler({UnauthenticatedException.class, UnknownAccountException.class})
    public String redirectLogin(){
        return "redirect:/login.jsp";
    }

    @ExceptionHandler({UnauthorizedException.class})
    public String noRight(){
        return "noright";
    }
}
